#include <functional>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>

using namespace std;

class Person
{
private:
	string name;
public:
	Person(const string& n) : name(n)
	{}

	void print() const
	{
		cout << name << endl;
	}

	void print2(const string& prefix) const {
		cout << prefix << name << endl;
	}

	static void print3(const string &_name)
	{
		cout << _name << endl;
	}
};

int bind2()
{
	vector<Person> coll = { Person("Tick"), Person("Trick"), Person("Track") };

	// call member function print() for each person
	for_each(coll.begin(), coll.end(), bind(&Person::print, std::placeholders::_1));
	cout << endl;

	// call member function printf2() with additional argument for each person
	for_each(coll.begin(), coll.end(), bind(&Person::print2, std::placeholders::_1, "Person: "));
	cout << endl;

	// call print2() for temporary Person
	bind(&Person::print2, std::placeholders::_1, "This is: ")(Person("nico"));

	// call static member function
	bind(&Person::print3, "yy")();
	return 0;
}